<?php

namespace XWAM\Controller;

/**
 * Description of XwamConfigController
 *
 * @since 1.0 <2016-6-20> SoChishun <14507247@qq.com> Added.
 * @since 1.1 2016-7-6 SoChishun XWAMConfig 重构为 XwamConf
 */
class XwamConf extends AppbaseController {

    function store_list_search() {
        $search = I('param.');
        if ($search['word']) {
            $where['_string'] = sprintf("title like '%s'", $search['word']);
        }
        // $where['site_id'] = $this->site_id;
        return array('where' => $where, 'search' => $search);
    }

    // 2016-5-26
    function store_list() {
        $asearch = $this->store_list_search();
        $m_conf = new \XWAM\Model\StoreConfModel();
        $list = $m_conf->selectPaging($page, array('where' => $asearch['where'], 'order' => 'sort, id desc'), array('page_params' => $asearch['search']));
        unset($m_conf);
        $this->assign('list', $list);
        $this->assign('page', $page->showBootstrap());
        $this->assign('search', $asearch['search']);
        $this->display();
    }

    // 2016-4-21
    public function site_setting($site_id = 0, $user_name = '') {
        if (!$site_id) {
            $site_id = $this->siteId;
            $user_name = $this->userName;
        }
        $m_site = new \XWAM\Model\XwamConfModel();
        $data = $m_site->findSite($site_id, $user_name);
        $this->assign('data', $data);
        $this->display();
    }

    public function site_setting_save() {
        $m_site = new \XWAM\Model\XwamConfModel();
        $result = $m_site->save_site();
        $this->dialogJump($result['status'], $result['info']);
    }

}
